package com.jia.leetCode;

/**
 * @program: Leetcode
 * @description: 371. Sum of Two Integers
 * @author: STU756
 * @create: 2020-08-16 22:25
 */
public class Pro0371 {
    //递归
    public int getSum(int a, int b) {
        if(b == 0) return a;
        int temp = a;
        a = a ^ b;
        b = (temp & b) << 1;
        return getSum(a, b);
    }
    //迭代
    public int getSum2(int a, int b) {
        while(b!= 0) {
            int temp = a;
            a = a ^ b;
            b = (temp & b) << 1;
        }
        return a;
    }
}
